<template>
  <div class="dashboard-container">
    <div class="dashboard-text">当前餐厅：{{restaurant}}</div>
    <div class="dashboard-text">管理员：{{name}}</div>
    <div class="tablestatus">
      <div class="total">总  餐  桌：{{tableTotal}}</div>
      <div class="unused">剩余餐桌：{{tableUnused}}</div>
    </div>

  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { tablestatus } from '@/api/dash'

export default {
  name: 'dashboard',
  computed: {
    ...mapGetters([
      'name',
      'restaurant'
    ])
  },
  data(){
    return {
      tableTotal:0,
      tableUnused:0
    }
  },
  created(){
    this.getTable()
  },
  methods:{
    getTable:function(){
      tablestatus().then(res => {
        this.tableTotal = res.data.total
        this.tableUnused = res.data.unused
        console.log(res)
      }).catch(err => {
        console.log(err)
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 20px;
    line-height: 46px;
    font-family: '微软雅黑';
    color: #304156;
  }
}
.tablestatus{
  width: 12%;
  height: 80px;
  border-style: solid;
  border-width: 1px;
  border-color: #304156;
  border-radius: 10px;
  padding: 5px;
  float: right;
  margin-top: -80px;
}
.total{
  color: #304156;
  font-size: 18px;
  margin-top: 10px;
  margin-left: 5px;
}
.unused{
  color: darkorange;
  font-size: 18px;
  margin-top: 5px;
  margin-left: 5px;
}
</style>
